//
// Created by Toosan on 2022/4/27.
//
#include "iostream"

using namespace std;

class Student {
private:
    int age;
    string name;
    int id;
public:
    Student() = default;;

    void setAge(int age_) {
        this->age = age_;
    }

    int getAge() const {
        return this->age;
    }

    void setName(string name_) {
        this->name = name_;
    }

    string getName() {
        return this->name;
    }

    void setId(int id_) {
        this->id = id_;
    }

    int getId() const {
        return this->id;
    }

    void printInfo() {
        cout << "id = " << id << ", name = " << name << endl;
    }
};

/**
 * C++中是没有抽象类和接口的概念的  纯虚函数和全纯虚函数都是类别Java中的抽象和接口，方便理解
 * 当一个类中全是纯虚函数，那么这个类就是全纯虚函数了，类似Java中的接口了。
 */
class IStudentDataBase {
    virtual void insert(Student student) = 0;

    virtual void remove(int id) = 0;

    virtual void update(Student student) = 0;

    virtual void query(int id) = 0;

};

/**
 * 全纯虚函数的实现类
 */
class IStudentDataBaseImp : public IStudentDataBase {
public:
    void insert(Student student) override {
        cout << "insert" << endl;
        student.printInfo();
    }

    void remove(int id) override {
        cout << "remove" << endl;
    }

    void query(int id) override {
        cout << "query" << endl;
    }


    void update(Student student) override {
        cout << "update" << endl;
        student.printInfo();
    }
};

/**
 * 全纯虚函数  == Java接口
 * @return
 */
int main() {
    Student student;
    student.setId(1);
    student.setName("toosan");
    student.setAge(18);
    IStudentDataBaseImp dataBase;
    dataBase.update(student);
    return 0;
}